//package com.xyy.kingdeejdy.helper;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.xyy.kingdeejdy.enums.TaskEnum;
//import com.xyy.kingdeejdy.pojo.pop.ApiRPCResult;
//import com.xyy.kingdeejdy.pojo.pop.ResultDto;
//import com.xyy.kingdeejdy.pojo.pop.SellerOrderInfoDto;
//import com.xyy.kingdeejdy.pojo.pop.TaskQueryParam;
//import com.xyy.kingdeejdy.utils.IpUtils;
//import com.xyy.kingdeejdy.utils.MD5Util;
//import com.xyy.kingdeejdy.utils.http.RedirectUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Component;
//import org.springframework.util.CollectionUtils;
//
//import java.net.InetAddress;
//import java.util.List;
//import java.util.Map;
//
///**
// * @Author itmei
// * @Date 2023/7/30 12:27
// * @description: pop接口请求
// * @Title: PopApi
// * @Package com.xyy.kingdeejdy.helper
// */
//@Slf4j
//@Component
//public class PopApi {
//    @Value("${pop.orgId}")
//    private String orgId;
//
//    @Value("${pop.appId}")
//    private String AppId;
//
//    @Value("${pop.appSecret}")
//    private String AppSecret;
//
//
//    public static <T> List<T> pullDataInfo(Integer taskId, Class<T> tClass) {
//        //构建pop订单查询参数
//        //构建查询pop参数
//        Map<String, Object> objectMap = buildPopTaskQueryParam(taskId, null);
//        String body = RedirectUtil.doGetParam("https://h-api.ybm100.com/api/hackTask/pullDataInfo", objectMap);
//        ApiRPCResult<ResultDto> apiRPCResult = JSON.parseObject(body, ApiRPCResult.class);
//        if (apiRPCResult == null || apiRPCResult.isFail()) {
//            log.warn("#平台订单下推失败 taskQueryParam:{}, apiRPCResult：{}", JSONObject.toJSONString(objectMap), JSON.toJSONString(apiRPCResult));
//            return null;
//        }
//        if (apiRPCResult.getData() == null) {
//            log.warn("#平台暂时无可拉取订单 apiRPCResult：{}", JSON.toJSONString(apiRPCResult));
//            return null;
//        }
//        ResultDto resultData = JSON.parseObject(JSON.toJSONString(apiRPCResult.getData()), ResultDto.class);
//        String dataJson = resultData.getDataJson();
//        log.info("#拉取到的订单信息: CustomerDataInfo: {}", dataJson);
//        //解析pop订单
//        //List<SellerOrderInfoDto> sellerOrderInfoDtos =
//        List<T> ts = JSON.parseArray(dataJson, tClass);
//        return ts;
//    }
//
//    public static  <T> Map<String, Object> buildPopTaskQueryParam(Integer taskId, List<T> list) {
//        TaskQueryParam taskQueryParam = new TaskQueryParam();
//        taskQueryParam.setOrgId(orgId);
//        taskQueryParam.setAppId(AppId);
//        if (taskId != null && taskId != 00000) {
//            taskQueryParam.setTaskId(taskId);
//        }
//        if (taskId == 00000) {
//            String ipAddress = "";
//            InetAddress address = IpUtils.getLocalHostLANAddress();
//            if (address != null) {
//                ipAddress = address.getHostAddress();
//            }
//            taskQueryParam.setVersion("3.5");
//            taskQueryParam.setJsonData(ipAddress);
//        }
//        if (!CollectionUtils.isEmpty(list)) {
//            taskQueryParam.setJsonData(JSON.toJSONString(list));
//        }
//        Map<String, Object> popParamMap = JSON.parseObject(JSON.toJSONString(taskQueryParam)).getInnerMap();
//        taskQueryParam.setSign(MD5Util.encrypt(popParamMap, AppSecret));
//        Map<String, Object> popParamMapNew = JSON.parseObject(JSON.toJSONString(taskQueryParam)).getInnerMap();
//        return popParamMapNew;
//    }
//
//}
